package LeetCode;

import java.util.Scanner;

public class No2105 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        String[] chs = s.split(",");

        int[] a = new int[chs.length];
        for (int i = 0; i < chs.length; i++) {
            a[i] = Integer.parseInt(chs[i]);
        }
        int capacityA=sc.nextInt();
        int capacityB=sc.nextInt();
        System.out.println(minimumRefill(a,capacityA,capacityB));
    }
    public static int minimumRefill(int[] plants, int capacityA, int capacityB) {
        int left=0,right = plants.length-1;
        int now_capacityA = capacityA;
        int now_capacityB = capacityB;
        int n=0;
        while(left<right){
            //System.out.println(right+"B:"+now_capacityB+" "+n);
            if(now_capacityA<plants[left]){
                n++;
                now_capacityA = capacityA-plants[left];
                plants[left]=0;
                //System.out.println(left+"A:"+now_capacityA+" "+n);
            } else{
                now_capacityA-=plants[left];
                plants[left]=0;
                //System.out.println(left+"A:"+now_capacityA);
            }
            left++;
            if(now_capacityB<plants[right]){
                n++;
                now_capacityB = capacityB-plants[right];
                plants[right]=0;
                //System.out.println(right+"B:"+now_capacityB+" "+n);
            } else{
                now_capacityB-=plants[right];
                //System.out.println(right+"B:"+now_capacityB);
                plants[right]=0;
            }
            right--;
            //System.out.println("now_capacityB"+now_capacityB);
        }
        if(left==right&&plants[left]!=0){
            if(now_capacityA>=now_capacityB){
                if(now_capacityA<plants[left]){
                    n++;
                    plants[left]=0;
                }
            }else {
                if(now_capacityB<plants[left]){
                    n++;
                    plants[left]=0;
                }
            }
        }
//        for (int i = 0; i < plants.length; i++) {
//            System.out.print(plants[i]+" ");
//        }
        return n;
    }
}
